from django.db import models
import time


# 测试题
class Quizzes(models.Model):
    id = models.AutoField(primary_key=True)
    quizzes = models.CharField(max_length=255)  # 测试题

    class Meta:
        db_table = 'quizzes'


# 测试题
class Questionnaire(models.Model):
    id = models.AutoField(primary_key=True)
    title = models.CharField(max_length=255)  # 测试题名称
    tips = models.TextField()  # 说明
    apply = models.TextField(null=True)  # 适用
    options = models.JSONField()  # 选项
    result = models.JSONField()  # 结果
    quizzes = models.JSONField()  # 测试题ID

    class Meta:
        db_table = 'questionnaire'


def advisory():
    return []


class User(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(max_length=255)  # 名称
    email = models.EmailField()  # 邮箱
    pwd = models.CharField(max_length=255)  # 密码
    head = models.URLField(default='/static/images/head.jpg')  # 头像
    data = models.JSONField()  # 测试题数据
    sex = models.BooleanField(null=True)  # 性别
    age = models.IntegerField(default=16)  # 年纪
    last_login = models.CharField(max_length=30)  # 登录时间
    advisory = models.JSONField(default=advisory)  # 咨询记录

    class Meta:
        db_table = 'users'
